<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ControlLoaderInfo>" %>
<%@ Import Namespace="Vit.CMS" %>
<%@ Import Namespace="Vit.CMS.Data" %>
<script type="text/javascript">
var layouts = <%= DataSources.GetJsonLayouts() %>;
var cl = '<%= this.Model.PageInfo.Layout %>';
var cs = '<%= this.Model.PageInfo.Skin %>';
var ct = '<%= this.Model.PageInfo.PageTemplate %>';
$(function(){
    $('#DesignLayout_Url').empty();
    $.each(layouts, function(i){
        $('#DesignLayout_Url').append('<option value="'+this.LayoutName+'>'+this.LayoutName+'</option>');
    });
    $('#DesignSkin_Url').change(function(){
        cs = $(this).val();
    });
    $('#PageTemplate').change(function(){
        ct = $(this).val();
        var w = $(window).width() - 50;
        var h = $(window).height() - 60;
        $('#design').attr('href','/<%= this.Model.PageInfo.FilePath.VirtualPagePath() %>?width='+w+'&height='+h+'&l='+ cl +'&s='+cs+'&t='+ct+'&TB_iframe=1&modal=true');
    });
    $('#DesignLayout_Url').change(function(){
        var ly;
        cl = $(this).val();
        for(var i=0; i<layouts.length; i++){
            if(layouts[i].LayoutName == cl){
                ly = layouts[i];
                break;
            }
        }
        if(ly){
            $('#DesignSkin_Url').empty();
            $.each(ly.Skins, function(i){
                $('#DesignSkin_Url').append('<option value="'+this+'>'+this+'</option>');
            });
            if(cs != '')
                $('#DesignSkin_Url').val(cs);
            $('#PageTemplate').empty();
            $.each(ly.PageTemplates, function(i){
                $('#PageTemplate').append('<option value="'+this+'>'+this+'</option>');
            });
            if(ct != '')
                $('#PageTemplate').val(ct);
            $('#PageTemplate').trigger('change');
        }
    });
    
    if(cl != '')
        $('#DesignLayout_Url').val(cl);
});
</script>
<fieldset>
    <legend><%= Html.Localize("ControlLoaderInfo")%></legend>
    <p>
        <div class="span-4"><%= Html.LabelFor(o=>o.ID) %></div>
        <div class="span-6"><%= Html.EditorFor(o => o.ID)%></div>
        <div class="span-2"><%= Html.ValidationMessage("ID")%></div>
    </p>
    <p>
        <div class="span-4"><%= Html.LabelFor(o => o.LoadOnce)%></div>
        <div class="span-6"><%= Html.EditorFor(o => o.LoadOnce)%></div>
    </p>
    <p>
        <div class="span-4"><%= Html.LabelFor(o => o.UrlReplaceWithUserProfile)%></div>
        <div class="span-6"><%= Html.EditorFor(o => o.UrlReplaceWithUserProfile)%></div>
    </p>
    <p>
        <div class="span-4"><%= Html.LabelFor(o => o.UrlReplaceWithRouteData)%></div>
        <div class="span-6"><%= Html.EditorFor(o => o.UrlReplaceWithRouteData)%></div>
    </p>
    <p>
        <div class="span-4"><%= Html.LabelFor(o => o.Url)%></div>
        <div class="span-6">
            <select id="DesignLayout_Url" name="DesignLayout.Url"></select>
        </div>
    </p>
    <p>
        <div class="span-4"><%= Html.LabelFor(o => o.PageInfo.DesignSkin.ID)%></div>
        <div class="span-6"><%= Html.EditorFor(o => o.PageInfo.DesignSkin.ID)%></div>
        <div class="span-2"><%= Html.ValidationMessage("DesignSkin.ID")%></div>
    </p>
    <p>
        <div class="span-4"><%= Html.LabelFor(o => o.PageInfo.DesignSkin.Url)%></div>
        <div class="span-6">
            <select id="DesignSkin_Url" name="DesignSkin.Url"></select>
        </div>
    </p>
    <p>
        <div class="span-4"><%= Html.LabelFor(o => o.PageInfo.PageTemplate)%></div>
        <div class="span-6">
            <select id="PageTemplate" name="PageTemplate"></select>
        </div>
    </p>
</fieldset>
<a id='design' class="thickbox"><%= Html.Localize("Design") %></a>
